{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "0f739c21",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "*  2023-10-09\n",
    "* 课程：python语言\n",
    "* week05\n",
    "\n",
    "----"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "202af8d0",
   "metadata": {},
   "source": [
    "# 1.用户输入\n",
    "> 1. input()\n",
    "> 2. input输出的数据类型是： string（字符串）"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "89bb7e64",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "name:hoki\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "'hoki'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "input(\"name:\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "846f7706",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入用户名:hoki\n",
      "请输入密码:123456\n"
     ]
    }
   ],
   "source": [
    "# 用户注册\n",
    "username = input(\"请输入用户名:\")\n",
    "password = input(\"请输入密码:\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "3964e68e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "hoki\n"
     ]
    }
   ],
   "source": [
    "print(username)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "57621efc",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "123456\n"
     ]
    }
   ],
   "source": [
    "print(password)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1f0ca36c",
   "metadata": {},
   "source": [
    "* 妙计：两个=是等于的意思"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "fce2db48",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "欢迎尊贵的vvip用户登录！！!\n"
     ]
    }
   ],
   "source": [
    "# 用户登录\n",
    "if username == \"hoki\" and password == \"123456\":\n",
    "    print(\"欢迎尊贵的vvip用户登录！！!\")\n",
    "else:\n",
    "    print(\"账号或密码错误，请重新尝试！！！\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "53bef080",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入用户名:hoki\n",
      "请输入密码:123456\n",
      "欢迎尊贵的vvip用户登录！！!\n"
     ]
    }
   ],
   "source": [
    "# 用户注册\n",
    "username = input(\"请输入用户名:\")\n",
    "password = input(\"请输入密码:\")\n",
    "# 用户登录\n",
    "if username == \"hoki\" and password == \"123456\":\n",
    "    print(\"欢迎尊贵的vvip用户登录！！!\")\n",
    "else:\n",
    "    print(\"账号或密码错误，请重新尝试！！！\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "085796d4",
   "metadata": {},
   "source": [
    "#  2.用户规范化/格式化输出"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "60901621",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "输入你的姓名:hoki\n",
      "输入你的年龄:18\n",
      "输入你的职业:CEO\n",
      "输入你的薪资:99999999999999\n",
      "---INFO hoki---\n",
      "你的姓名是：hoki\n",
      "你的年龄为：18\n",
      "你的职业是：CEO\n",
      "你的薪资为: 99999999999999\n"
     ]
    }
   ],
   "source": [
    "#输入的内容\n",
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info 为展示的数据\n",
    "info = \"\"\"-------INFO %s------\n",
    "你的姓名是：%s\n",
    "你的年龄为：%s\n",
    "你的职业是：%s\n",
    "你的薪资为: %s\"\"\"%(name,name,age,job,salary)\n",
    "\n",
    "#打印结果\n",
    "print(info)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "090a5ff1",
   "metadata": {},
   "source": [
    "* 占位符:\n",
    "> 1. 顺序\n",
    "> 2. %s 代表 字符串 %d 代表数字（整数） %f 代表小数\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0a1f54a4",
   "metadata": {},
   "outputs": [],
   "source": [
    "#输入的内容（后端）\n",
    "name = input(\"输入你的姓名:\")\n",
    "age = input(\"输入你的年龄:\")\n",
    "job = input(\"输入你的职业:\")\n",
    "salary = input(\"输入你的薪资:\")\n",
    "\n",
    "# info 为展示的数据（前端）\n",
    "info = \"\"\"-------INFO %s------\n",
    "你的姓名是：{N}\n",
    "你的年龄为：{A}\n",
    "你的职业是：{J}\n",
    "你的薪资为: {S}\"\"\".format(N=name,J=jobage,A=age,S=salary) #减少了占位符顺序带来的混乱\n",
    "\n",
    "#打印结果\n",
    "print(info)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
